// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var dialog = require("dialog");
	var validate = require("validate");
	var leftMenu = require("../leftMenu/leftMenu");
	var topMenu = require("../topMenu/topMenu");
	var router = require("../hash/pageRouter");
	var css_financingDetailInfo = require("../financing/financingDetailInfo.css");
	var css_param = require("./approvelCarefulManage.css");
	var css_common = require("../../../css/common.css");
	var valuationCal = require("valuationCal");
	var tools = require("tools");
	var databind = require("databind");
	var constant = require("constant");
	var pickupId;
	var financeId;
	var bulkstockList;
	var $this;
    var html_bulkstockInfo = require("./html_bulkstockInfo.html");//查询货物弹出框内容
	var init = function(page) {
		pickupId = page.params.pickupId || base.getUrlParam("pickupId");
		initPickUpDetail(pickupId);
		initEvent();
		router.init();
//		leftMenu.init(11);
		inquireCurrentOperationList();
	};
	var initEvent = function() {
		
		$("#approvelCarefulManage .prints").unbind("click").click(function(){
			tools.printit($("#approvelCarefulManage"),'preview');
		});
		//查看审批记录
		$("#approvelCarefulManage .auditRecord").unbind("click").click(function(){
//			window.open("../auditRecord/pickUpGoodsAuditRecord.html?recordType=7&recordId=" + pickupId);
			window.open("../auditRecord/auditRecord.html?recordType=7&recordId=" + pickupId);
		});
		
		$(".footButton .button-Yes").on("click", function() {
			$("#approvelCarefulManage .content1").attr("action", "consentFinanceApplication");
		
			if ($(".financeAmountInput").val()*1 > $(".applicationAmount").html()*1) {
				dialog.showConfirmDialog("融资审批", "审批金额大于申请金额，是否确认？", function(){
					databind.submitDom($(".content1"), function() {
						base.alert(1, "审核通过成功");
						router.route("warehousePickup/wareHousePickupList.html", true);
						databind.disableInput($(".content1"));
						$(".button-Yes").remove();
						$(".button-No").remove();
					});
				});
			} else {
				databind.submitDom($(".content1"), function() {
					base.alert(1, "审核通过成功");
					router.route("warehousePickup/wareHousePickupList.html", true);
					inquireFinanceLatestAuditDetail();
					databind.disableInput($(".content1"));
					$(".button-Yes").remove();
					$(".button-No").remove();
				});
			}    
		});
		
		$("#businessAudit .button-Yes").unbind("click").click(function(){
			preservationBussinessAuditOpinion();
		});
		
		$("#businessAudit .button-Save").unbind("click").click(function(){	
		var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitBussinessAuditOpinion();
			});
		});
		
		$("#businessManageAudit .button-Yes").unbind("click").click(function(){
			preservationLeaderBussinessAuditOpinion();
		});
		
		$("#businessManageAudit .button-Save").unbind("click").click(function(){
			var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitLeaderBussinessAuditOpinion();
			});
		});
		
		$("#operationAudit .button-Yes").unbind("click").click(function(){
			preservationOperateBussinessAuditOpinion()
		});
		
		$("#operationAudit .button-Save").unbind("click").click(function(){
			var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitOperateBussinessAuditOpinion();
			});
		});
	
	$("#riskAudit .button-Yes").unbind("click").click(function(){
		preservationRiskBussinessAuditOpinion();
	});
	
	$("#riskAudit .button-Save").unbind("click").click(function(){	
	var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				submitRiskBussinessAuditOpinion();
		});
	});
	
	$("#riskMemberAudit .button-Yes").unbind("click").click(function(){
		preservationRiskAdminBussinessAuditOpinion();
	});
	
	$("#riskMemberAudit .button-Save").unbind("click").click(function(){
		var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				submitRiskAdminBussinessAuditOpinion();
		});
	});
	
	$("#financialAudit .button-Yes").unbind("click").click(function(){
		preservationFinanceBussinessAuditOpinion()
	});
	
	$("#financialAudit .button-Save").unbind("click").click(function(){
		var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitFinanceBussinessAuditOpinion();
			});
	});

	$("#financialManageAudit .button-Yes").unbind("click").click(function(){
		preservationFinanceAdminBussinessAuditOpinion();
	});
	
	$("#financialManageAudit .button-Save").unbind("click").click(function(){	
		var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitFinanceAdminBussinessAuditOpinion();
			});
		});
	
	$("#operationManageAudit .button-Yes").unbind("click").click(function(){
		preservationViceManagerBussinessAuditOpinion();
	});
	
	$("#operationManageAudit .button-Save").unbind("click").click(function(){
			var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitViceManagerBussinessAuditOpinion();
			});
		});
	
	$("#ceoAudit .button-Yes").unbind("click").click(function(){
		preservationManagerBussinessAuditOpinion()
	});
	
	$("#ceoAudit .button-Save").unbind("click").click(function(){
			var ii5 = layer.confirm('是否确认提交？提交后不可再次修改。', {
				  btn: ['确定','取消'] //按钮
				}, function(){
					submitManagerBussinessAuditOpinion();
			});
		});
	
	tools.fileupload($("#approvelCarefulManage #filesUuid1"), null, function(data){
		var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
		$("#approvelCarefulManage .addfile").before(str);
		var filesUuid6 = [];
		$.each($('#approvelCarefulManage .mas'), function() {
			filesUuid6.push($(this).attr("fileUuid"));
		});
		$("#approvelCarefulManage input[name=filesUuid]").val(filesUuid6);
	});
	
	$("#approvelCarefulManage").on("click", ".removeFile", function(){
		$(this).parents(".showFiles").remove();
		var filesUuid6 = [];
		$.each($('#createPickup .mas'), function() {
			filesUuid6.push($(this).attr("fileUuid"));
		});
		$("#createPickup input[name=filesUuid]").val(filesUuid6);
	});
	
	//查看融资详情
	$("#approvelCarefulManage tr[class='trFinanceDetail']").hide();
	$("#approvelCarefulManage").on("click", ".showFinanceDetail", function() {
		var $thisParent = $(this).parents("tr");
		var financeId = $thisParent.attr("financeId");
		if($thisParent.next().is(":hidden")) {
			$thisParent.next().show();
			$(this).html("&nbsp;&nbsp;[-]");
		}else {
			$thisParent.next().hide();
			$(this).html("&nbsp;&nbsp;[+]");
		}
		
		if($thisParent.next().attr("isNull") != "1") {
			inquireFinanceApplicationDetail($thisParent.next(),financeId);
		}
	});
	
	//点击融资编号
	$("#approvelCarefulManage .order_num").unbind("click").click(function() {
		router.route("financing/financingDetailInfo.html?financeId=" + $(this).parents("tr").attr("financeId"));
	});

	};
	
	//提货详情
	var initPickUpDetail = function(pickupId) {
		base.fnAjax({
			action: "inquireFinancePickupApplicationWarehouse.json",
			async: false,
			oData: {
				pickupId: pickupId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					if(data.datas.length > 0) {
						
						juicer.register("formatCurrency", tools.formatCurrency);
						juicer.register("getValueByKey", constant.getValueByKey);
						juicer.register("inquireFile", tools.inquireFile);
						var pickUpInfoTmpl = $("#approvelCarefulManage .pitl").html();
						
						var html = juicer(pickUpInfoTmpl, data);
						$("#approvelCarefulManage .content1").html(html);
						if(data.datas[0].filesUuid != undefined) {
							var filesUuid = data.datas[0].filesUuid;
							financeId = data.datas[0].bulkstockList[0].financeId;
							var tableBody = "";
							var index = 1;
							$.each(filesUuid.split(","), function() {
								var _this = this;
								if($.trim(_this) != "") {
									tableBody += '<tr><td>'+index+'</td><td>'+ tools.inquireFile(_this) +'</td><td><a target="_blank" class="table_details_link" fileUuid="' + _this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + _this + '" >' + "预览" + '</a></td></tr>';
								}
								index = index + 1;
							});
							
							$("#approvelCarefulManage .fileUuidBody").html(tableBody);
							databind.disableInput($("#approvelCarefulManage"));
							databind.enableInput($("#approvelCarefulManage .supplementOpinion"));
							databind.enableInput($("#approvelCarefulManage .location")); 

						}
						
						//提货信息合计
						var supervisionQuantitys = 0;
						$.each($("#approvelCarefulManage .supervisionQuantity"), function() {
							supervisionQuantitys += parseFloat($(this).attr("supervisionQuantity"));
						});
						$("#approvelCarefulManage #supervisionQuantitys").html(tools.formatCurrency(supervisionQuantitys));
						
						var pickupQuantitys = 0;
						$.each($("#approvelCarefulManage .pickupQuantity"), function() {
							pickupQuantitys += parseFloat($(this).attr("pickupQuantity"));
						});
						$("#approvelCarefulManage #pickupQuantitys").html(tools.formatCurrency(pickupQuantitys));
						
						var bulkstockAmount = 0;
						$.each($("#approvelCarefulManage .bulkstockAmount"), function() {
							bulkstockAmount += parseFloat($(this).attr("bulkstockAmount"));
						});
						$("#approvelCarefulManage #bulkstockAmount").html(tools.formatCurrency(bulkstockAmount));
						
						var interest = 0;
						$.each($("#approvelCarefulManage .interest"), function() {
							interest += parseFloat($(this).attr("interest"));
						});
						$("#approvelCarefulManage #interest").html(tools.formatCurrency(interest));
						
						var others = 0;
						$.each($("#approvelCarefulManage .others"), function() {
							others += parseFloat($(this).attr("others"));
						});
						$("#approvelCarefulManage #others").html(tools.formatCurrency(others));
						
						var pickupAmounts = 0;
						$.each($("#approvelCarefulManage .pickupAmount"), function() {
							pickupAmounts += parseFloat($(this).attr("pickupAmount"));
						});
						$("#approvelCarefulManage #pickupAmounts").html(tools.formatCurrency(pickupAmounts));
					
						tools.clearNoNumAll($("#approvelCarefulManage"));		
						
						databind.fillForm($("#approvelCarefulManage"), data.datas[0]);
						
	
						
						if(data.datas[0].submissionStatus !=0){
							$("#businessAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus2 !=0){
							$("#businessManageAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus3 !=0){
							$("#operationAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus4 !=0){
							$("#riskAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus5 !=0){
							$("#riskMemberAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus6 !=0){
							$("#financialAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus7 !=0){
							$("#financialManageAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus8 !=0){
							$("#operationManageAudit .button-submit").remove();
						}
						if(data.datas[0].submissionStatus9 !=0){
							$("#ceoAudit .button-submit").remove();
						}
						
						if ($("#riskAudit .submitState").val() == "false" || $("#riskAudit .submitState").val() == "") {
//							$("#riskMemberAudit .button-submit").remove();
							$("#financialAudit .button-submit").remove();
							$("#financialManageAudit .button-submit").remove();
							$("#operationManageAudit .button-submit").remove();
//							$("#ceoAudit .button-submit").remove();
						} 
//						else if ($("#riskMemberAudit .submitState").val() == "false") {
//							$("#financialAudit .button-submit").remove();
//							$("#financialManageAudit .button-submit").remove();
//							$("#operationManageAudit .button-submit").remove();
//							$("#ceoAudit .button-submit").remove();
//						} 
						else if ($("#financialAudit .submitState").val() == "false") {
							$("#financialManageAudit .button-submit").remove();
							$("#operationManageAudit .button-submit").remove();
//							$("#ceoAudit .button-submit").remove();
						} 
						else if ($("#financialManageAudit .submitState").val() == "false") {
							$("#operationManageAudit .button-submit").remove();
//							$("#ceoAudit .button-submit").remove();
						}
						else if($("#operationManageAudit .submitState").val() == "false"){
//							$("#ceoAudit .button-submit").remove();
						}
						
						if ($("#approvelCarefulManage select[name=auditState]").val() == null){
							$("select[name=auditState]").html("<option>"+data.datas[0].auditState == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState2]").val() == null){
							$("select[name=auditState2]").html("<option>"+data.datas[0].auditState2 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState3]").val() == null){
							$("select[name=auditState3]").html("<option>"+data.datas[0].auditState3 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState4]").val() == null){
							$("select[name=auditState4]").html("<option>"+data.datas[0].auditState4 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState5]").val() == null){
							$("select[name=auditState5]").html("<option>"+data.datas[0].auditState5 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState6]").val() == null){
							$("select[name=auditState6]").html("<option>"+data.datas[0].auditState6 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState7]").val() == null){
							$("select[name=auditState7]").html("<option>"+data.datas[0].auditState7 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState8]").val() == null){
							$("select[name=auditState8]").html("<option>"+data.datas[0].auditState8 == false?"拒绝":"同意"+"</option>");
						}
						if ($("#approvelCarefulManage select[name=auditState9]").val() == null){
							$("select[name=auditState9]").html("<option>"+data.datas[0].auditState9 == false?"拒绝":"同意"+"</option>");
						}
						
						databind.fillForm($("#businessAudit"), {"submissionStatus_1": data.datas[0].submissionStatus == false?"待提交":"已提交"});
						
						databind.fillForm($("#businessManageAudit"), {"submissionStatus_2": data.datas[0].submissionStatus2 == false?"待提交":"已提交"});
						databind.fillForm($("#operationAudit"), {"submissionStatus_3": data.datas[0].submissionStatus3 == false?"待提交":"已提交"});
						databind.fillForm($("#riskAudit"), {"submissionStatus_4": data.datas[0].submissionStatus4 == false?"待提交":"已提交"});
						databind.fillForm($("#riskMemberAudit"), {"submissionStatus_5": data.datas[0].submissionStatus5 == false?"待提交":"已提交"});
						databind.fillForm($(".requireInput"), {"pickupState": data.datas[0].pickupState == 0?"待提交":"已提交"});
						
						if(data.datas[0].submissionStatus6 == true){
							var str="";
							$.each(data.datas[0].filesUuid6.split(','), function() {
								var _this = this;						
								if($.trim(_this) != "") {
									 str +=  '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + _this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + _this + '" class="showProductIntro">' + tools.inquireFile(_this)+ '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
								}
							});
		//					console.log(str+"abc");
		//					console.log($("#addFile"));
							$("#addFile").html(str);
						}
						databind.fillForm($("#financialAudit"), {"submissionStatus_6": data.datas[0].submissionStatus6 == false?"待提交":"已提交"});
						databind.fillForm($("#financialManageAudit"), {"submissionStatus_7": data.datas[0].submissionStatus7 == false?"待提交":"已提交"});
						databind.fillForm($("#operationManageAudit"), {"submissionStatus_8": data.datas[0].submissionStatus8 == false?"待提交":"已提交"});
						databind.fillForm($("#ceoAudit"), {"submissionStatus_9": data.datas[0].submissionStatus9 == false?"待提交":"已提交"});
						var pickupState
						if(data.datas[0].pickupState == 0 ){
							 pickupState="未知";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 1 ){
							 pickupState="已取消";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 2 ){
							 pickupState="初审中";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 3 ){
							 pickupState="合同待上传";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 4 ){
							 pickupState="合同待提交";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 5 ){
							 pickupState="待客户签署";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 6 ){
							 pickupState="待平台签署";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 7 ){
							 pickupState="合同待确认";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 8 ){
							 pickupState="合同已打回";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
						if(data.datas[0].pickupState == 9 ){
							 pickupState="平台已签署";
							 databind.fillForm($(".requireInput"), {"pickupState": pickupState});
						}
	
					  }
						
					if (data.datas[0].pickupState != 10) {
						databind.disableInput($("#approvelCarefulManage"));
						$("#approvelCarefulManage .button-submit").remove();
					}
					
					var step = 1;
					if (data.datas[0].finalId == 25) {
						step = 1;
					} else if (data.datas[0].finalId == 5) {
						step = 2;
					} else if (data.datas[0].finalId == 3) {
						step = 3;
					} else if (data.datas[0].finalId == 9) {
						step = 4;
					} else if (data.datas[0].finalId == 10) {
						step = 5;
					} else if (data.datas[0].finalId == 20) {
						step = 6;
					} else if (data.datas[0].finalId == 14) {
						step = 7;
					}
				  	
				  	$.each($("#approvelCarefulManage table tr"), function() {
						
						var _this = $(this)
						if (_this.attr("financeNumber") != null && _this.attr("financeNumber") != "") {
							inquireFinanceApplicationDetailByFinanceNUmber(_this.attr("financeNumber"), function(data){
						  		//回调
						  		_this.find(".financeNumber").append(data.datas[0].financeNumber + '<input type="hidden" name="financeNumbers" value="'+data.datas[0].financeNumber+'" /><input type="hidden" name="financeIds" value="'+data.datas[0].financeId+'" />');
						  		_this.find(".productType").html(constant.getValueByKey(7, data.datas[0].productType));
						  		_this.find(".financeBulkstock").html(data.datas[0].bulkstocks[0].bulkstockName + "(" + data.datas[0].bulkstocks[0].specification + ")");
						  		_this.find(".waitReceipt").html(tools.formatCurrency(data.datas[0].totalLoanAmount - data.datas[0].totalReceivedAmount));
						  	});
						}
			
					});
					
					tools.stepBar($("#approvelCarefulStepBar"), step, [{name: "商务部审核", id: 1}, {name: "运营审核", id: 2}, {name: "风控审核", id: 3}, {name: "资金审核", id: 4}, {name: "资金领导审核", id: 5}, {name: "副总经理审核", id: 6}, {name: "审核完成", id: 7}]);
				}else {
					base.alert(2, "获取信息失败");
					return;
				}
			}
		});
	};
	
	//权限控制
    var inquireCurrentOperationList = function(){
        base.fnAjax({
            action: 'inquireCurrentOperationList.json',
            async:false,
            fnSuccess: function (data) {
                if (data.status == 200) {
                    for(var i=0;i<data.datas.length;i++){
                        var permission = data.datas[i];
                        var permissionId = permission.permissionId;
                        $.each($("#approvelCarefulManage").find("input"), function() {
                        	var $this = $(this);
                        	if($this.attr("permissionId") == permissionId){
                        		$this.removeClass("none");
                        	}
                        });
                    }
                } else {
                    base.alert(3, data.message);
                }
            }
        });
    };
    
    var preservationBussinessAuditOpinion =function(){
		var auditState =$("#approvelCarefulManage select[name=auditState]").val();
		var auditRemark =$("#approvelCarefulManage textarea[name=auditRemark]").val();
		base.fnAjax({
			action : "preservationBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState : auditState,
				auditRemark : auditRemark
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitBussinessAuditOpinion =function(){
		var auditState =$("#approvelCarefulManage select[name=auditState]").val();
		var auditRemark =$("#approvelCarefulManage textarea[name=auditRemark]").val();
		base.fnAjax({
			action : "submitBussinessAuditOpinions.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState : auditState,
				auditRemark : auditRemark
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
						base.alert(1, "保存成功!");
						router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
					window.location.reload(); 
				}
			}
		});
	};
	
	var preservationLeaderBussinessAuditOpinion =function(){
		var auditState2 =$("#approvelCarefulManage select[name=auditState2]").val();
		var auditRemark2 =$("#approvelCarefulManage textarea[name=auditRemark2]").val();
		base.fnAjax({
			action : "preservationLeaderBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState2 : auditState2,
				auditRemark2 : auditRemark2
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
    
	var submitLeaderBussinessAuditOpinion =function(){
		var auditState2 =$("#approvelCarefulManage select[name=auditState2]").val();
		var auditRemark2 =$("#approvelCarefulManage textarea[name=auditRemark2]").val();
		base.fnAjax({
			action : "submitLeaderBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState2 : auditState2,
				auditRemark2 : auditRemark2
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var preservationOperateBussinessAuditOpinion =function(){
		var auditState3 =$("#approvelCarefulManage select[name=auditState3]").val();
		var auditRemark3 =$("#approvelCarefulManage textarea[name=auditRemark3]").val();
		base.fnAjax({
			action : "preservationOperateBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState3 : auditState3,
				auditRemark3 : auditRemark3
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
    
	var submitOperateBussinessAuditOpinion =function(){
		var auditState3 =$("#approvelCarefulManage select[name=auditState3]").val();
		var auditRemark3 =$("#approvelCarefulManage textarea[name=auditRemark3]").val();
		base.fnAjax({
			action : "submitOperateBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState3 : auditState3,
				auditRemark3 : auditRemark3
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationRiskBussinessAuditOpinion =function(){
		var auditState4 =$("#approvelCarefulManage select[name=auditState4]").val();
		var auditRemark4 =$("#approvelCarefulManage textarea[name=auditRemark4]").val();
		base.fnAjax({
			action : "preservationRiskBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState4 : auditState4,
				auditRemark4 : auditRemark4
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitRiskBussinessAuditOpinion =function(){
		var auditState4 =$("#approvelCarefulManage select[name=auditState4]").val();
		var auditRemark4 =$("#approvelCarefulManage textarea[name=auditRemark4]").val();
		base.fnAjax({
			action : "submitRiskBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState4 : auditState4,
				auditRemark4 : auditRemark4
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationRiskAdminBussinessAuditOpinion =function(){
		var auditState5 =$("#approvelCarefulManage select[name=auditState5]").val();
		var auditRemark5 =$("#approvelCarefulManage textarea[name=auditRemark5]").val();
		base.fnAjax({
			action : "preservationRiskAdminBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState5 : auditState5,
				auditRemark5 : auditRemark5
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitRiskAdminBussinessAuditOpinion =function(){
		var auditState5 =$("#approvelCarefulManage select[name=auditState5]").val();
		var auditRemark5 =$("#approvelCarefulManage textarea[name=auditRemark5]").val();
		base.fnAjax({
			action : "submitRiskAdminBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState5 : auditState5,
				auditRemark5 : auditRemark5
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationFinanceBussinessAuditOpinion =function(){
		var auditState6 =$("#approvelCarefulManage select[name=auditState6]").val();
		var auditRemark6 =$("#approvelCarefulManage textarea[name=auditRemark6]").val();
		var filesUuid6=$("#approvelCarefulManage input[name=filesUuid]").val();
		base.fnAjax({
			action : "preservationFinanceBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState6 : auditState6,
				auditRemark6 : auditRemark6,
				filesUuid6 : filesUuid6
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitFinanceBussinessAuditOpinion =function(){
		var auditState6 =$("#approvelCarefulManage select[name=auditState6]").val();
		var auditRemark6 =$("#approvelCarefulManage textarea[name=auditRemark6]").val();
		var filesUuid6=$("#approvelCarefulManage input[name=filesUuid]").val();
		base.fnAjax({
			action : "submitFinanceBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState6 : auditState6,
				auditRemark6 : auditRemark6,
				filesUuid6 : filesUuid6
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationFinanceAdminBussinessAuditOpinion =function(){
		var auditState7 =$("#approvelCarefulManage select[name=auditState7]").val();
		var auditRemark7 =$("#approvelCarefulManage textarea[name=auditRemark7]").val();
		base.fnAjax({
			action : "preservationFinanceAdminBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState7 : auditState7,
				auditRemark7 : auditRemark7
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitFinanceAdminBussinessAuditOpinion =function(){
		var auditState7 =$("#approvelCarefulManage select[name=auditState7]").val();
		var auditRemark7 =$("#approvelCarefulManage textarea[name=auditRemark7]").val();
		base.fnAjax({
			action : "submitFinanceAdminBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState7 : auditState7,
				auditRemark7 : auditRemark7
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationViceManagerBussinessAuditOpinion =function(){
		var auditState8 =$("#approvelCarefulManage select[name=auditState8]").val();
		var auditRemark8 =$("#approvelCarefulManage textarea[name=auditRemark8]").val();
		base.fnAjax({
			action : "preservationViceManagerBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState8 : auditState8,
				auditRemark8 : auditRemark8
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitViceManagerBussinessAuditOpinion =function(){
		var auditState8 =$("#approvelCarefulManage select[name=auditState8]").val();
		var auditRemark8 =$("#approvelCarefulManage textarea[name=auditRemark8]").val();
		base.fnAjax({
			action : "submitViceManagerBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState8 : auditState8,
				auditRemark8 : auditRemark8
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};

	 var preservationManagerBussinessAuditOpinion =function(){
		var auditState9 =$("#approvelCarefulManage select[name=auditState9]").val();
		var auditRemark9 =$("#approvelCarefulManage textarea[name=auditRemark9]").val();
		base.fnAjax({
			action : "preservationManagerBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState9 : auditState9,
				auditRemark9 : auditRemark9
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	var submitManagerBussinessAuditOpinion =function(){
		var auditState9 =$("#approvelCarefulManage select[name=auditState9]").val();
		var auditRemark9 =$("#approvelCarefulManage textarea[name=auditRemark9]").val();
		base.fnAjax({
			action : "submitManagerBussinessAuditOpinion.json",
			async : false, // 同步异步
			oData : {
				pickupId : pickupId,
				auditState9 : auditState9,
				auditRemark9 : auditRemark9
			}, // 传递参数
			fnSuccess : function(data) {
				if (data.status == 200) {
					base.alert(1, "保存成功!");
					router.route("warehousePickup/approvelCarefulManage.html?pickupId=" + pickupId);
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	//查询融资详情
	var inquireFinanceApplicationDetail = function(dom,financeId) {
		base.fnAjax({
			action: "inquireFinanceApplicationDetail.json",
			nocode: true,
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					var d = {};
					d.loanDate = data.datas[0].loanDate;
					d.loanAmount = tools.formatCurrency(data.datas[0].loanAmount);
					d.intrerst = data.datas[0].auditInterest;
					d.pledgeRate = (parseFloat(data.datas[0].financeAuditDetail.financeAmount)*100/parseFloat(data.datas[0].bulkstocks[0].finalPrice)).toFixed(2);
					d.financeDays = data.datas[0].financeProductInnerDetail.financeDays;
					d.bulkstockPrice = tools.formatCurrency(data.datas[0].bulkstocks[0].bulkstockPrice);
					d.financePrice = tools.formatCurrency(data.datas[0].bulkstocks[0].financePrice);
					
					databind.fillForm(dom, d);
					
					dom.attr("isNull", "1");
				}else {
					//
				}
			}
		})
	};
	
	//查询融资详情
	var inquireFinanceApplicationDetailByFinanceNUmber = function(financeNumber, callback) {
//		if (financeNumber == null || financeNumber == "") {
//			base.alert(3, "请输入融资编号！");
//			return false;
//		}
		
		base.fnAjax({
			action: "inquireFinanceApplicationDetailByFinanceNUmber.json",
			nocode: true,
			oData: {
				financeNumber: financeNumber
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					callback(data);
				}else {
					base.alert(3, data.message);
				}
			}
		})
	};

	return {
		init: init
	};
});